<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\common\controller;

use app\common\model\jooj_config\SoaUsers as SoaUsersModel;
use app\common\common\Helper;

/**
 * Description of AuthBase
 *
 * @author dxx
 */
class AuthBase extends Base {

    public function __construct(\think\Request $request = null) {
        Helper::$requestTime = microtime(true);
        parent::__construct($request);
        $this->_checkToken();
    }

    private function _checkToken() {

        $appId = input('param.appid'); 
        $appSecret = input('param.app_secret');

        $SoaUsersModel = new SoaUsersModel();

//        try {
            $userInfo = $SoaUsersModel->getUserInfo($appId, $appSecret);
//        } catch (\Exception $e) {
//            return $this->output([],  $e->getMessage(), '0000');
//        }

        if (!$userInfo['id']) {
            return $this->output([], 'check UserInfo error', '999999');
        }

        $this->_apiUserInfo = $userInfo;

        return true;
    }
    
}
